package com.journey.controller.api;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.journey.domain.Business;
import com.journey.dto.AdDto;
import com.journey.dto.BusinessDto;
import com.journey.dto.BusinessListDto;
import com.journey.service.AdService;
import com.journey.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * Created by ADMIN on 2018/6/7.
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    @Autowired
    private AdService adService;

    @Autowired
    private BusinessService businessService;

    @RequestMapping(value = "/homead" , method = RequestMethod.GET)
    public List<AdDto> homead(){
        AdDto adDto = new AdDto();
        return adService.searchByPage(adDto);
    }

    @RequestMapping(value = "/homelist/{city}/{page.currentPage}" , method = RequestMethod.GET)
    public BusinessListDto homelist(BusinessDto businessDto) throws IOException{
//        businessDto.getPage().setPageNumber(businessHomeNumber);
        return businessService.searchByPageForApi(businessDto);
    }


}
